/* ==========================================================================
   漫画阅读器主样式文件
   ========================================================================== */

/* 基础重置和变量 */
:root {
    /* 主题颜色 */
    --primary-color: #2196F3;
    --primary-light: #64B5F6;
    --primary-dark: #1976D2;
    --secondary-color: #FF9800;
    --accent-color: #4CAF50;
    --error-color: #F44336;
    --warning-color: #FF9800;
    
    /* 背景颜色 */
    --bg-primary: #FFFFFF;
    --bg-secondary: #F5F5F5;
    --bg-tertiary: #EEEEEE;
    --bg-dark: #212121;
    --bg-card: #FFFFFF;
    
    /* 文字颜色 */
    --text-primary: #212121;
    --text-secondary: #757575;
    --text-tertiary: #BDBDBD;
    --text-inverse: #FFFFFF;
    
    /* 边框和阴影 */
    --border-color: #E0E0E0;
    --border-radius: 8px;
    --shadow-light: 0 2px 4px rgba(0,0,0,0.1);
    --shadow-medium: 0 4px 8px rgba(0,0,0,0.12);
    --shadow-heavy: 0 8px 16px rgba(0,0,0,0.15);
    
    /* 间距 */
    --spacing-xs: 4px;
    --spacing-sm: 8px;
    --spacing-md: 16px;
    --spacing-lg: 24px;
    --spacing-xl: 32px;
    --spacing-xxl: 48px;
    
    /* 字体 */
    --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'Helvetica Neue', Helvetica, Arial, sans-serif;
    --font-mono: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
    
    /* 过渡 */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.3s ease;
    --transition-slow: 0.5s ease;
    
    /* 层级 */
    --z-header: 1000;
    --z-modal: 2000;
    --z-tooltip: 3000;
    --z-loading: 9999;
}

/* 全局重置 */
*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    font-size: 16px;
    line-height: 1.5;
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
}

body {
    margin: 0;
    padding: 0;
    font-family: var(--font-family);
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-primary);
    background-color: var(--bg-secondary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* 基础排版 */
h1, h2, h3, h4, h5, h6 {
    margin: 0 0 var(--spacing-md) 0;
    font-weight: 600;
    line-height: 1.3;
}

h1 { font-size: 2rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.25rem; }
h4 { font-size: 1.125rem; }
h5 { font-size: 1rem; }
h6 { font-size: 0.875rem; }

p {
    margin: 0 0 var(--spacing-md) 0;
}

a {
    color: var(--primary-color);
    text-decoration: none;
    transition: color var(--transition-fast);
}

a:hover {
    color: var(--primary-dark);
}

img {
    max-width: 100%;
    height: auto;
    vertical-align: middle;
}

/* 按钮样式 */
.btn, .action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-sm) var(--spacing-md);
    border: none;
    border-radius: var(--border-radius);
    font-family: inherit;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: all var(--transition-fast);
    user-select: none;
    white-space: nowrap;
    gap: var(--spacing-xs);
}

.btn:disabled,
.action-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn.primary,
.action-btn.primary {
    background-color: var(--primary-color);
    color: var(--text-inverse);
}

.btn.primary:hover,
.action-btn.primary:hover {
    background-color: var(--primary-dark);
}

.btn.secondary,
.action-btn.secondary {
    background-color: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn.secondary:hover,
.action-btn.secondary:hover {
    background-color: var(--bg-tertiary);
}

.btn.danger {
    background-color: var(--error-color);
    color: var(--text-inverse);
}

.btn.danger:hover {
    background-color: #D32F2F;
}

/* 表单元素 */
.form-group {
    margin-bottom: var(--spacing-md);
}

.form-label {
    display: block;
    margin-bottom: var(--spacing-xs);
    font-weight: 500;
    color: var(--text-primary);
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: var(--spacing-sm) var(--spacing-md);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    font-family: inherit;
    font-size: 14px;
    background-color: var(--bg-card);
    transition: border-color var(--transition-fast);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* 卡片组件 */
.card {
    background-color: var(--bg-card);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-light);
    overflow: hidden;
    transition: box-shadow var(--transition-normal);
}

.card:hover {
    box-shadow: var(--shadow-medium);
}

.card-header {
    padding: var(--spacing-md);
    border-bottom: 1px solid var(--border-color);
}

.card-body {
    padding: var(--spacing-md);
}

.card-footer {
    padding: var(--spacing-md);
    border-top: 1px solid var(--border-color);
    background-color: var(--bg-secondary);
}

/* 导航栏 */
.navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
    background-color: var(--bg-card);
    box-shadow: var(--shadow-light);
    z-index: var(--z-header);
}

.nav-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 var(--spacing-md);
}

.nav-brand a {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

.brand-icon {
    font-size: 24px;
}

.nav-menu {
    display: flex;
    align-items: center;
    gap: var(--spacing-lg);
}

.nav-link {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: var(--spacing-xs);
    color: var(--text-secondary);
    font-size: 12px;
    transition: color var(--transition-fast);
}

.nav-link:hover,
.nav-link.active {
    color: var(--primary-color);
}

.nav-icon {
    font-size: 18px;
}

.nav-toggle {
    display: none;
    flex-direction: column;
    gap: 4px;
    cursor: pointer;
    padding: var(--spacing-xs);
}

.nav-toggle span {
    width: 24px;
    height: 2px;
    background-color: var(--text-primary);
    transition: all var(--transition-fast);
}

/* 主要内容区域 */
.main-content {
    margin-top: 60px;
    min-height: calc(100vh - 60px);
    padding: var(--spacing-lg);
}

/* 页脚 */
.footer {
    background-color: var(--bg-card);
    border-top: 1px solid var(--border-color);
    text-align: center;
    padding: var(--spacing-lg);
    color: var(--text-secondary);
    font-size: 12px;
}

/* 消息提示 */
.flash-messages {
    position: fixed;
    top: 70px;
    right: var(--spacing-md);
    z-index: var(--z-modal);
    max-width: 400px;
}

.flash-message {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--spacing-md);
    margin-bottom: var(--spacing-sm);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-medium);
    animation: slideInRight 0.3s ease;
}

.flash-success {
    background-color: #E8F5E8;
    color: #2E7D32;
    border-left: 4px solid var(--accent-color);
}

.flash-error {
    background-color: #FFEBEE;
    color: #C62828;
    border-left: 4px solid var(--error-color);
}

.flash-warning {
    background-color: #FFF3E0;
    color: #E65100;
    border-left: 4px solid var(--warning-color);
}

.flash-close {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    color: inherit;
    padding: 0;
    margin-left: var(--spacing-sm);
}

/* 加载动画 */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: var(--z-loading);
}

.loading-spinner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--spacing-md);
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.loading-text {
    color: var(--text-inverse);
    font-size: 14px;
}

/* 首页样式 */
.home-container {
    max-width: 1200px;
    margin: 0 auto;
}

.welcome-section {
    text-align: center;
    padding: var(--spacing-xxl) 0;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-light));
    border-radius: var(--border-radius);
    color: var(--text-inverse);
    margin-bottom: var(--spacing-xl);
}

.welcome-title {
    font-size: 2.5rem;
    margin-bottom: var(--spacing-md);
}

.welcome-subtitle {
    font-size: 1.125rem;
    opacity: 0.9;
    margin-bottom: var(--spacing-xl);
}

.quick-actions {
    display: flex;
    gap: var(--spacing-md);
    justify-content: center;
    flex-wrap: wrap;
}

.stats-section {
    margin-bottom: var(--spacing-xl);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--spacing-md);
}

.stat-card {
    background-color: var(--bg-card);
    border-radius: var(--border-radius);
    padding: var(--spacing-lg);
    text-align: center;
    box-shadow: var(--shadow-light);
    transition: transform var(--transition-normal);
}

.stat-card:hover {
    transform: translateY(-2px);
}

.stat-icon {
    font-size: 2rem;
    margin-bottom: var(--spacing-sm);
}

.stat-number {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: var(--spacing-xs);
}

.stat-label {
    color: var(--text-secondary);
    font-size: 14px;
}

/* 漫画网格 */
.comics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-xl);
}

.comic-card {
    background-color: var(--bg-card);
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: var(--shadow-light);
    transition: all var(--transition-normal);
}

.comic-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-medium);
}

.comic-cover {
    position: relative;
    aspect-ratio: 3/4;
    overflow: hidden;
}

.cover-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform var(--transition-normal);
}

.comic-card:hover .cover-image {
    transform: scale(1.05);
}

.cover-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    background-color: var(--bg-tertiary);
    color: var(--text-tertiary);
}

.placeholder-icon {
    font-size: 2rem;
    margin-bottom: var(--spacing-xs);
}

.comic-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(to top, rgba(0,0,0,0.8), transparent);
    opacity: 0;
    transition: opacity var(--transition-normal);
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    padding: var(--spacing-md);
}

.comic-card:hover .comic-overlay {
    opacity: 1;
}

.comic-stats {
    display: flex;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-sm);
}

.stat-badge {
    background-color: rgba(255, 255, 255, 0.2);
    padding: 2px var(--spacing-xs);
    border-radius: 12px;
    font-size: 12px;
    color: var(--text-inverse);
}

.comic-meta {
    padding: var(--spacing-md);
}

.comic-title {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: var(--spacing-xs);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.comic-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    font-size: 12px;
    color: var(--text-secondary);
}

.info-row {
    display: flex;
    justify-content: space-between;
}

/* 分页组件 */
.pagination-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--spacing-md);
    margin-top: var(--spacing-xl);
}

.pagination {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.page-btn {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    background-color: var(--bg-card);
    color: var(--text-primary);
    transition: all var(--transition-fast);
}

.page-btn:hover {
    background-color: var(--primary-color);
    color: var(--text-inverse);
    border-color: var(--primary-color);
}

.page-info {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    font-weight: 600;
    margin: 0 var(--spacing-md);
}

.current-page {
    color: var(--primary-color);
}

.pagination-info {
    font-size: 12px;
    color: var(--text-secondary);
}

/* 动画 */
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 工具类 */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

.d-none { display: none; }
.d-block { display: block; }
.d-flex { display: flex; }
.d-grid { display: grid; }

.align-center { align-items: center; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }

.gap-xs { gap: var(--spacing-xs); }
.gap-sm { gap: var(--spacing-sm); }
.gap-md { gap: var(--spacing-md); }
.gap-lg { gap: var(--spacing-lg); }

.m-0 { margin: 0; }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.ml-0 { margin-left: 0; }
.mr-0 { margin-right: 0; }

.p-0 { padding: 0; }
.pt-0 { padding-top: 0; }
.pb-0 { padding-bottom: 0; }
.pl-0 { padding-left: 0; }
.pr-0 { padding-right: 0; }

/* 响应式断点预设 */
@media (max-width: 1200px) {
    .nav-container,
    .home-container {
        max-width: 100%;
        padding-left: var(--spacing-md);
        padding-right: var(--spacing-md);
    }
}

@media (max-width: 768px) {
    :root {
        --spacing-md: 12px;
        --spacing-lg: 18px;
        --spacing-xl: 24px;
        --spacing-xxl: 32px;
    }
    
    .main-content {
        padding: var(--spacing-md);
    }
    
    .nav-menu {
        position: fixed;
        top: 60px;
        left: 0;
        right: 0;
        background-color: var(--bg-card);
        box-shadow: var(--shadow-medium);
        flex-direction: column;
        padding: var(--spacing-md);
        gap: var(--spacing-md);
        transform: translateY(-100%);
        opacity: 0;
        visibility: hidden;
        transition: all var(--transition-normal);
    }
    
    .nav-menu.active {
        transform: translateY(0);
        opacity: 1;
        visibility: visible;
    }
    
    .nav-toggle {
        display: flex;
    }
    
    .nav-toggle.active span:nth-child(1) {
        transform: rotate(45deg) translate(5px, 5px);
    }
    
    .nav-toggle.active span:nth-child(2) {
        opacity: 0;
    }
    
    .nav-toggle.active span:nth-child(3) {
        transform: rotate(-45deg) translate(7px, -6px);
    }
    
    .nav-link {
        flex-direction: row;
        justify-content: flex-start;
        padding: var(--spacing-sm);
        font-size: 14px;
    }
    
    .comics-grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
        gap: var(--spacing-sm);
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
        gap: var(--spacing-sm);
    }
    
    .welcome-title {
        font-size: 1.8rem;
    }
    
    .welcome-subtitle {
        font-size: 1rem;
    }
    
    .quick-actions {
        flex-direction: column;
        align-items: center;
    }
    
    .flash-messages {
        right: var(--spacing-sm);
        left: var(--spacing-sm);
        max-width: none;
    }
}